package com.game.message;

import com.game.message.messagecode.GameServerMsgStage;
import com.game.message.messagecode.MsgStage;

import java.io.Serializable;

/**
 * 各种消息的父类
 * Created by legend9999 on 2016/6/26.
 */
public class Msg implements Serializable{
    public static int headLength = 4;
    private int msgId;
    private int userId;
    private byte[] body = new byte[0];

    public int getLength() {
        return headLength + body.length;
    }

    public int getMsgId() {
        return msgId;
    }

    public void setMsgId(int msgId) {
        this.msgId = msgId;
    }

    public byte[] getBody() {
        return body;
    }

    public void setBody(byte[] body) {
        this.body = body;
    }


    public int getUserId() {
        return userId;
    }

    public void setUserId(int userId) {
        this.userId = userId;
    }

    public int getSID() {
       return (msgId % MsgStage.REQ) / GameServerMsgStage.BASE;
    }
    @Override
    public String toString() {
        return String.format("msgId=%s", msgId);
    }
}
